package com.example.artgallery.ui

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import coil.compose.AsyncImage
import com.example.artgallery.model.Artwork

@Composable
fun GalleryScreen(
    artworks: List<Artwork>,
    onBack: () -> Unit
) {
    Column(modifier = Modifier.fillMaxSize()) {
        Button(onClick = onBack) {
            Text("返回文件夹")
        }
        
        val pagerState = rememberPagerState(pageCount = { artworks.size })
        HorizontalPager(
            state = pagerState,
            modifier = Modifier.weight(1f)
        ) { page ->
            val artwork = artworks[page]
            AsyncImage(
                model = artwork.imagePath,
                contentDescription = artwork.title,
                contentScale = ContentScale.Fit
            )
        }
    }
}